package com.study.manage.dal;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.study.manage.domain.Evaluate;
import com.study.manage.domain.EvaluateBrandOrgRecommend;
import com.study.manage.domain.enumm.LiveDieState;

public interface EvaluateBrandOrgRecommendRepository
        extends PagingAndSortingRepository<EvaluateBrandOrgRecommend, Long> {

    int countByEvaluateIdAndState(Long evaluateId, LiveDieState state);

    @Query("select e.evaluateId from EvaluateBrandOrgRecommend e where e.userId=?1 and e.state=?2")
    List<Long> findByUserIdAndState(Long userId, LiveDieState state);

    @Query("select e from EvaluateBrandOrgRecommend e where e.evaluateId=?1 and e.state=?2")
    Page<EvaluateBrandOrgRecommend> findRecommends(Long evaluateId, LiveDieState state,
            Pageable pageable);



    @Query("select e from EvaluateBrandOrgRecommend t,Evaluate e where t.evaluateId=e.id and t.userId in (?1) and t.state=?2")
    Page<Evaluate> findEvaluateByUserIdInAndState(List<Long> userId, LiveDieState state,
            Pageable pageable);
}
